#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <math.h>

int zhisu(int w)
{
	if (w == 2)
		return w;
	else if (w == 1)
		return 0;
	else if (w % 2 != 0)
	{
		int r = 0;
		for (int i = 3; i <= sqrt(w); i += 2)
		{
			if (w % i == 0)
			{
				r = 1;
				break;
			}
		}
		if (r == 1)
			return 0;
		else
			return w;
	}
	else return 0;

}
int main()
{
	int n;
	scanf("%d", &n);
	int a[100] = { 0 };
	for (int i = 0; i < n; i++)
	{
		int q;
		scanf("%d", &q);
		a[i] = q;
	}
	for (int i = 0; i < n; i++)
	{
		int q = zhisu(a[i]);
		if (q != 0)
			printf("%d ", q);
	}

	return 0;

}

